
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
    #region AreaDetail Model -(by fangyifeng at 2007-09-14 12:23:53)

    /// <summary>
    /// AreaDetail object'AreaDetail'.
    /// </summary>
    [Serializable]
    public class AreaDetail : System.IComparable
    {
        #region Member Variables

        protected Guid _id;
        protected Area _area;
        protected Province _province;

        protected static String _sortExpression = "Id";
        protected static SortDirection _sortDirection = SortDirection.Ascending;

        #endregion

        #region Constructors

        public AreaDetail() { }

        public AreaDetail(Area area, Province province)
        {
            this._area = area;
            this._province = province;
        }

        #endregion

        #region Public Properties

        public virtual Guid Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public virtual Area Area
        {
            get { return _area; }
            set { _area = value; }
        }


        public virtual Province Province
        {
            get { return _province; }
            set { _province = value; }
        }


        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
        #endregion

        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
            if (!(obj is AreaDetail))
                throw new InvalidCastException("This object is not of type AreaDetail");

            int relativeValue;
            switch (SortExpression)
            {
                case "Id":
                    relativeValue = this.Id.CompareTo(((AreaDetail)obj).Id);
                    break;
                default:
                    goto case "Id";
            }
            if (AreaDetail.SortDirection == SortDirection.Ascending)
                relativeValue *= -1;
            return relativeValue;
        }
        #endregion
    }

    #endregion
}
